package com.system.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Classname CorsConfig
 * @Description TODO
 * @Date 2023/11/3 11:22
 * @Created by XiongXiong
 * @Author: X.I.O
 */
@Configuration
public class CorsConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/video/play") // 设置允许跨域的请求路径
                .allowedOrigins("http://127.0.0.1:8848") // 允许来自'http://127.0.0.1:8848'的跨域请求
                .allowedMethods("GET") // 允许的HTTP方法
                .allowedHeaders("Content-Type") // 允许的请求头
                .maxAge(3600); // 预检请求的缓存时间
    }
}
